package com.zs.toolbox.web2j.common.exception;

import com.zs.toolbox.web2j.common.response.WtBaseResponse;

/**
 * 描述：
 * <p>
 *
 * @author: eric.zhang
 * @date: 2018/4/11 23:06
 */
public class WtBaseException extends RuntimeException {
    Integer code = 100;

    WtBaseResponse baseResponse;

    public Integer getCode() {
        return code;
    }

    public WtBaseException setCode(Integer code) {
        this.code = code;
        return this;
    }

    public WtBaseResponse errorResponse() {
        if(baseResponse == null) {
            baseResponse = new WtBaseResponse(this.code,this.getMessage());
        }
        return baseResponse;
    }

    public WtBaseException(Integer code, String message, Throwable cause)  {
        super(message, cause);
        this.code = code;
    }

    public WtBaseException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    public WtBaseException(String message) {
        super(message);
    }

    public WtBaseException(String message, Throwable cause) {
        super(message, cause);
    }
}

